#pragma once

#include <iostream>
#include <string>

// 对相应的网络报文进行截取
bool ParseOneLine(std::string &str, std::string *out, const std::string &sep)
{
    auto pos = str.find(sep);
    if (pos == std::string::npos)
    {
        return false;
    }

    *out = str.substr(0, pos);

    str.erase(0, pos + sep.size());
    return true;
}

bool SplitString(std::string &header, const std::string &HeaderLineSep, std::string *key, std::string *value)
{
    auto pos=header.find(HeaderLineSep);
    if(pos==std::string::npos)
    {
        return false;
    }

    *key=header.substr(0,pos);

    *value=header.substr(pos+HeaderLineSep.size());
    return true;
}